package com.neutech.terrain;

import com.neutech.Util.ImageUtils;
import com.neutech.base.Drawable;
import com.neutech.base.Sprite;

import java.awt.*;

public class Wall extends Sprite implements Drawable {
    private transient Image image;
    /**
     * 数字都可以用枚举来解决，有名字，数字的优点是简单易用，缺点是代码不易读
     */
    /*强的类型，1代表砖墙，2代表铁墙*/
    public int wallType = 1;

    public Wall() {
    }

    public Wall(int x, int y, int width, int height, int wallType) {
        super(x, y, width, height);
        this.wallType = wallType;
    loadingImg();
    }



    @Override
    public void draw(Graphics g) {
        if (image == null){
            loadingImg();
        }
        g.drawImage(image,getX(),getY(),null);

    }

    @Override
    public Rectangle getRectangle() {
        return new Rectangle(getX(),getY(),getWidth(),getHeight());
    }
 public void loadingImg(){
        if (wallType ==1 ){
            image = ImageUtils.getValue("brick_wall");
        }else if (wallType == 2){
            image = ImageUtils.getValue("iron_wall");

        }
 }
}

